package com.hotel.service.impl;

import com.hotel.mapper.ItemMapper;
import com.hotel.pojo.Item;
import com.hotel.service.ItemService;
import com.hotel.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemServiceImpl implements ItemService {
    @Autowired
    private ItemMapper itemMapper;

    @Override
    public List<Item> findAll() {
        return itemMapper.findAll();
    }
    @Override
    public PageResult getItemList(PageResult pageResult) {
        Long total = itemMapper.getTotal();
        int size = pageResult.getPageSize();
        int start = (pageResult.getPageNum() - 1) * size;
        String query = pageResult.getQuery();
        List<Item> rows = itemMapper.findItemListByPage(start,size,query);
        return pageResult.setTotal(total).setRows(rows);
    }


}
